package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.OrderBO;
import com.jackiechancinema.ssm.dto.OrderExcelDto;
import com.jackiechancinema.ssm.entity.Commodit;
import com.jackiechancinema.ssm.entity.Order;
import com.jackiechancinema.ssm.entity.Schedule;
import com.jackiechancinema.ssm.service.Inte.OrderService;
import com.jackiechancinema.ssm.service.Inte.PerfService;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import com.sun.xml.internal.ws.resources.HttpserverMessages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api/order/")
public class OrderController {
    @Autowired
    private OrderService orderService;

//    @GetMapping("page")
//    public PageVo<Order> page(int page, int limit){
//        return orderService.page(page, limit);
//    }

    @GetMapping("page")
    public PageVo<Order> page(OrderBO orderBO){
        return orderService.page(orderBO);
    }

    @PostMapping("delete")
    public R delete(int id,HttpSession session){
        return orderService.delete(id,session );
    }

    @PostMapping("add")
    public R add(Order order, HttpSession session){
        return orderService.add(order,session);
    }

    //文件上传
    @PostMapping("batchadd")
    public R batch(MultipartFile file ,HttpSession session){
        return orderService.batchadd(file,session);
    }

    @GetMapping("download")
    public void download(OrderBO o,HttpServletResponse response){
            orderService.exportExcel(o,response);
    }

    @PostMapping("update")
    public R update(Order order ,HttpSession session){
        return orderService.update(order,session);
    }
}
